package com.apes.fn.scm.used.model;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import com.apes.scm.masterdata.finance.model.AmtReceipt;
import com.apes.scm.masterdata.finance.model.PaymentMethodType;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/***
 * 旧件出库单收款方式
 */


@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = UsedDeliverIncomeType.CONST_TABLE_NAME)
public class UsedDeliverIncomeType extends BaseModel {
    public static final String CONST_TABLE_NAME = "war_used_deliver_income_type";

    @Id
    @Column(name = "id", length = 16)
    @Comment("单号")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "旧件出库单收款方式")
    private String id;

    @Comment("出库单号")
    @NotNull
    @ManyToOne(optional = false)
    @JoinColumn(name = "used_deliver_id", referencedColumnName = "id", nullable=false)
    private UsedDeliver usedDeliver;  // 出库单号

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "amt_receipt_id", referencedColumnName = "id")
    @Comment("资金收入类型")
    private AmtReceipt amtReceipt;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="payment_method_type", referencedColumnName="id", nullable = false)
    @Comment("收款方式")
    private PaymentMethodType paymentMethodType;

    @Comment("资金收入")
    @Column(name = "money_income", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    private double moneyIncome = 0;//资金收入

    @Column(name = "remark", length = 200)
    @Comment("备注")
    private String remark;

    @Column(name = "account", length = 64)
    @Comment("账号")
    private String account;

    @Column(name = "account_name", length = 64)
    @Comment("账户简称")
    private String accountName;

}
